#include <stdio.h>
#include <stdlib.h>
#include <liblds/bintree.h>
/*             A
 *        /         \
 *       B           C
 *     /   \       /   \
 *    D     E     F     G
 *   / \   / \   / \   / \
 *  H   I J   K L   M N   O
 * */
char * new(){
	return (char*)malloc(sizeof(char));
}
void vist(void *data,void *v){
	printf("%c ",*(char *)data);
}
LBinTree* Init(LBinTree *Tree);
void print_tree();
int main()
{
	print_tree();
	LBinTree * Tree;
	Tree=Init_LBinTree();
	Tree=Init(Tree);
	printf("Pre Order Traverse\n");
	PreOrderTraverse_LBinTree(Tree,vist,NULL);
	putchar('\n');
	printf("In Order Traverse\n");
	InOrderTraverse_LBinTree(Tree,vist,NULL);
	putchar('\n');
	printf("Post Order Traverse\n");
	PostOrderTraverse_LBinTree(Tree,vist,NULL);
	putchar('\n');
	printf("Level Order Traverse\n");
	LevelOrderTraverse_LBinTree(Tree,vist,NULL);
	putchar('\n');
	Destroy_LBinTree(&Tree,free);
}
LBinTree * Init(LBinTree *Tree){
	char *a=new();
	char A='A';
	printf("%c ",A);
	*a=A; Assign_BinTree(Tree,"/",a,free); A++; a=new();
	printf("%c ",A);
	*a=A; Assign_BinTree(Tree,"/1",a,free); A++; a=new();
	printf("%c ",A);
	*a=A; Assign_BinTree(Tree,"/0",a,free); A++; a=new();
	printf("%c ",A);
	*a=A; Assign_BinTree(Tree,"/11",a,free); A++; a=new();
	printf("%c ",A);
	*a=A; Assign_BinTree(Tree,"/10",a,free); A++; a=new();
	printf("%c ",A);
	*a=A; Assign_BinTree(Tree,"/01",a,free); A++; a=new();
	printf("%c ",A);
	*a=A; Assign_BinTree(Tree,"/00",a,free); A++; a=new();
	printf("%c ",A);
	*a=A; Assign_BinTree(Tree,"/111",a,free); A++; a=new();
	printf("%c ",A);
	*a=A; Assign_BinTree(Tree,"/110",a,free); A++; a=new();
	printf("%c ",A);
	*a=A; Assign_BinTree(Tree,"/101",a,free); A++; a=new();
	printf("%c ",A);
	*a=A; Assign_BinTree(Tree,"/100",a,free); A++; a=new();
	printf("%c ",A);
	*a=A; Assign_BinTree(Tree,"/011",a,free); A++; a=new();
	printf("%c ",A);
	*a=A; Assign_BinTree(Tree,"/010",a,free); A++; a=new();
	printf("%c ",A);
	*a=A; Assign_BinTree(Tree,"/001",a,free); A++; a=new();
	printf("%c ",A);
	*a=A; Assign_BinTree(Tree,"/000",a,free); //A++; a=new();
	putchar('\n');
	return Tree;
}
void print_tree(){
	printf("             A\n");
	printf("        /         \\\n");
	printf("       B           C\n");
	printf("     /   \\       /   \\\n");
	printf("    D     E     F     G\n");
	printf("   / \\   / \\   / \\   / \\\n");
	printf("  H   I J   K L   M N   O\n\n");
}
